package com.atguigu.spzx.service.exception;

import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author MikeCoder
 * @create 2023-12-0211:18
 * @description:
 * @verson:
 */
@RestControllerAdvice
public class GlobalExceptionHandler {
        @ExceptionHandler(GuiguException.class)
        public Result guiguExceptionHandler(GuiguException exception){
            exception.printStackTrace();
            return Result.build(null,exception.getResultCodeEnum());
        }

        @ExceptionHandler(Exception.class)
        public Result systemExceptionHandler(Exception exception){
            exception.printStackTrace();
            return Result.build(null, ResultCodeEnum.SYSTEM_ERROR);
        }
}
